<script setup>
import {onMounted, reactive, ref} from "vue";
import {ipc} from "@/utils/ipcRenderer";
import {ipcApiRoute} from "@/api/main";

const settingForm = reactive({
  db_address: '',
  port: '',
  username: '',
  password: '',
  database: ''
})
const inited = ref(false)

const getConfig = async () => {
  console.log(ipc, 'ipc')
  const result = await ipc.invoke(ipcApiRoute.getSettingConfig)
  console.log(result, 're')
  Object.assign(settingForm, result)
  inited.value = true
  console.log(settingForm, 'settingForm')
}

onMounted(() => {
  getConfig()
})
</script>

<template>
  <div class="setting-wrapper">
    <a-form v-if="inited" :model="settingForm">
      <a-form-item label="数据库地址" >
        <a-input v-model="settingForm.db_address"></a-input>
      </a-form-item>
      <a-form-item label="数据库端口">
        <a-input v-model="settingForm.port"></a-input>
      </a-form-item>
      <a-form-item label="数据库账号">
        <a-input v-model="settingForm.username"></a-input>
      </a-form-item>
      <a-form-item label="数据库密码">
        <a-input-password v-model="settingForm.password"></a-input-password>
      </a-form-item>
    </a-form>
  </div>
</template>

<style lang="less" scoped>
.setting-wrapper {
  padding: 20px;
}
</style>